package com.grapevine.contact;

import com.grapevine.contact.config.ConfigKey;
import com.grapevine.contact.config.SharePrefareManager;

import android.app.Activity;
import android.content.SharedPreferences.Editor;
import android.view.View.OnClickListener;
import android.os.Bundle;
import android.view.View;

public class Control extends Activity implements OnClickListener
{

	private static final int REGISTER_MODE = 0;
	private static final int LOGIN_MODE = 1;
	private static final int NEW_INFOR_MODE = 2;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login);
		setView(LOGIN_MODE);
	}

	@Override
	protected void onResume()
	{
		super.onResume();
		Editor editor = SharePrefareManager.getEditor(this);
		editor.putInt(ConfigKey.CURRENT_ACTIVITY, 3);
		editor.commit();
	}
	
	private void setView(int mode)
	{

		switch (mode)
		{
		case REGISTER_MODE:
			findViewById(R.id.register_back).setOnClickListener(this);
			break;

		case LOGIN_MODE:
			findViewById(R.id.login_register).setOnClickListener(this);
			break;

		case NEW_INFOR_MODE:
			break;

		default:
			break;
		}

	}

	@Override
	public void onClick(View v)
	{
		switch (v.getId())
		{
		case R.id.login_register:
			setContentView(R.layout.register);
			setView(REGISTER_MODE);
			break;

		case R.id.register_back:
			setContentView(R.layout.login);
			setView(LOGIN_MODE);
			break;
		default:
			break;
		}

	}

}